package edu.sctu.zcy.month201505.day20150506;

/**
 * Created by user24 on 2015/5/6.
 */
public class MatrixMultiply {
    public static void main(String[] args) {

        int[][] a = {{2,3,4},{5,6,7}};
        int[][] b = {{1,2},{3,4},{5,6}};
        int[][] result = new int[a.length][b[0].length];


        for (int i = 0; i < result.length; i++)

            for (int j = 0; j < result[0].length; j++) {

                result[i][j] = 0;

                for (int k = 0; k < b.length; k++)
                    result[i][j] += a[i][k] * b[k][j];

            }

        System.out.println("矩阵a*b相乘结果：");

        for (int i = 0; i < result.length; i++)

            for (int j = 0; j < result[0].length; j++) {

                System.out.print(result[i][j] + " ");
                System.out.println();

        }
    }
}
